﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Design;

namespace Dycox.Windows.Forms.Design
{
    class QueryArgsSite : ISite
    {
        private IContainer _container;
        private IComponent _component;

        public QueryArgsSite(IContainer container, PropertyGrid component)
        {
            if (component == null)
                throw new ArgumentNullException("component");

            _component = component;
            _container = container;
        }

        public IComponent Component
        {
            get { return _component; }
        }

        public IContainer Container
        {
            get { return _container; }
        }

        public bool DesignMode
        {
            get { return false; }
        }

        private string _name;

        public string Name
        {
            get
            {
                return _name ?? this.GetType().Name;
            }
            set
            {
                _name = value;
            }
        }

        QueryFieldValueUIService _valueService;

        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(IPropertyValueUIService))
            {
                if (_valueService == null)
                    _valueService = new QueryFieldValueUIService();
                return _valueService;
            }

            return null;
        }
    }
}
